import { request } from '../request';

/**
 * Login
 *
 * @param userName User name
 * @param password Password
 */
export function fetchGetAllOrder(params?: Api.SystemManage.UserSearchParams) {
  return request<Api.Food.OrderList>({
    url: '/order',
    method: 'get',
    params
  });
}

export function fetchGetAllOrderByRunning(params?: Api.SystemManage.UserSearchParams) {
  return request<Api.Food.OrderList>({
    url: '/order?iscount=true',
    method: 'get',
    params
  });
}

/**
 * Refresh token
 *
 * @param refreshToken Refresh token
 */
export function fetchAddOrder(data?: Api.Food.Order) {
  return request<Api.Food.Order>({
    url: '/order',
    method: 'post',
    data
  });
}

export function fetchDeleteOrder(id: any) {
  return request<Api.Food.Order>({
    url: `/${id}/order`,
    method: 'delete'
  });
}

export function fetchDeleteBatchOrder(ids: string[]) {
  return request<Api.Food.Order>({
    url: `/order`,
    method: 'delete',
    data: {
      ids
    }
  });
}

export function fetchEditOrder(id: number, data?: Api.Food.Order) {
  return request<Api.Food.Order>({
    url: `/${id}/order`,
    method: 'put',
    data
  });
}

export function fetchPatchOrder(id: number, data?: any) {
  return request<Api.Food.Order>({
    url: `/${id}/order`,
    method: 'patch',
    data
  });
}

export function fetchPrintOrder(id: number, data?: any) {
  return request<Api.Food.Order>({
    url: `/${id}/order?onlyprint=true`,
    method: 'patch',
    data
  });
}
